﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace geopg_wp7
{
    public partial class SettingsPage : PhoneApplicationPage
    {
        public SettingsPage()
        {
            InitializeComponent();
        }

        private void save_Click(object sender, EventArgs e)
        {
            // Checks, which RadioButton is checked
            if (radioButton1.IsChecked == true)
                ChangeLanguage("de-DE");

            if (radioButton2.IsChecked == true)
                ChangeLanguage("en-US");
        }

        private void login_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("//LoginPage.xaml", UriKind.Relative));
        }

        private void mainPage_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("//MainPage.xaml", UriKind.Relative));
        }

        private void localPictures_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("//LocalPicturesPage.xaml", UriKind.Relative));
        }

        private void settings_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("//SettingsPage.xaml", UriKind.Relative));
        }

        private void info_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("//InfoPage.xaml", UriKind.Relative));
        }

        // Method to save language-settings to IsolatedStorage
        private void ChangeLanguage(string lang)
        {
            // Remove old setting
            System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Remove("language");
            // Add new setting
            System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Add("language", lang);
            // Save the setting
            System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Save();
            MessageBox.Show("Settings saved! Language is set to: " + lang + " -- Please restart the application for changes to take effect.");
        }
    }
}